var table;
function init() {
	$('#start').val(params.startTime);
	$('#end').val(params.endTime);
	$('#start').datetimepicker({
		format : 'yyyy-mm-dd hh:ii',
		autoclose : true,
		endDate : new Date(),
		todayHighlight : true
	});
	$('#end').datetimepicker({
		format : 'yyyy-mm-dd hh:ii',
		autoclose : true,
		endDate : new Date(),
		pickerPosition : 'bottom-left',
		todayHighlight : true
	});
	initData();
}
function initData() {
	var start = $('#start').val();
	var end = $('#end').val();
	var loading = layer.load(1, {
	  shade: [0.5,'#fff'] //0.1透明度的白色背景
	});
	$.getJSON("/rest/thunder/getEquipmentThunderMsg/" + start
			+ "/" + end +"/"+params.ename, function(result) {
		layer.close(loading);
		loadTable(result);
	});
}
function loadTable(result) {
	if (table) {
		table.getTable().destroy();
	}
	var columns = ['序号','一次设备','时间','杆塔号','距离(m)','电流(kA)','回击'];
	var opt = MyTable.getDefaultOptions();
	opt.paging = false;
	opt.scrollY = 500;
	table = new MyTable("datatable", columns, opt);
	for(var i in result){
		result[i][1] = DateUtil.dateTime(result[i][1]);
		result[i].unshift(Number(i)+1);
	}
	table.setDataSet(result).show();
}
function query(){
	initData();	
}